# -*- coding: utf-8 -*-
import scrapy


class LoginGithubSpider(scrapy.Spider):
    name = 'login_github'
    allowed_domains = ['github.com']
    start_urls = ['https://github.com/login']

    def parse(self, response):
        yield scrapy.FormRequest.from_response(response,formdata={
            'login':'luckyy199213',
            'password':'199213xiao..'
        },callback=self.res_settings)

    def res_settings(self,response):
        yield scrapy.Request('https://github.com/settings/profile',callback=self.save_file)


    def save_file(self,response):
        with open('github.html','w',encoding='utf-8') as f:
            f.write(response.text)